package org.wendu.wdoa.check.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wendu.wdoa.check.dto.CheckDto;
import org.wendu.wdoa.check.service.CheckService;
import org.wendu.wdoa.common.CurrentUser;
import org.wendu.wdoa.common.Result;
import org.wendu.wdoa.common.WdoaConstants;
import org.wendu.wdoa.common.token.TokenUtils;

import java.util.Map;

@RestController
@RequestMapping("/check")
public class CheckApi {
    @Autowired
    private CheckService checkService;
    @GetMapping("/checkTask")
    public Result checkTask(@RequestHeader(WdoaConstants.HEADER_NAME_TOKEN) String clientToken, CheckDto checkDto){
        CurrentUser currentUser = TokenUtils.getCurrentUser(clientToken);
        Map<String,Object> page = checkService.findCheckTaskList(currentUser.getUserId(),checkDto);
        return Result.OK(page);
    }
    @PostMapping("/yanShouCurrentTask")
    public Result yanShouCurrentTask(@RequestBody CheckDto checkDto){
        checkService.yanShouCurrentTask(checkDto);
        return Result.OK();
    }
}
